package com.atguigu.gmall.mq.controller;

import com.atguigu.gmall.common.config.service.RabbitService;
import com.atguigu.gmall.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/mq")
@Slf4j
public class MqController {

    @Autowired
    private RabbitService rabbitService;

    @Autowired
    private RabbitTemplate rabbitTemplate;

    //  编写发送消息的控制器！
    @GetMapping("sendConfirm")
    public Result sendConfirm(){
        //  调用发送消息方法
        rabbitService.sendMessage("exchange.confirm","routing.confirm","死鬼，才回来！");
        //  返回数据
        return Result.ok();
    }
}